<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>编辑角色</title>
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/animate.min.css" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/style.min.css?v=4.0.0" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/plugins/toastr/toastr.min.css" rel="stylesheet">
<script type="text/javascript">

function initradio(rName){
    var rObj = document.getElementsByName(rName);
    var rVal = ${role.itemstatus};

    for(var i = 0;i < rObj.length;i++){
        if(rObj[i].value == rVal){
        	
            rObj[i].checked =  'checked';
        }
    }
}
</script>	
</head>

<body >


	<div class="ibox-content">

		<form id="subForm" method="post" class="form-horizontal"
			onsubmit="return addRole()">
			<input type="hidden" name="id" value="${role.id}" />
		
			<div class="form-group">
				<label class="col-sm-2 control-label">项目名称：</label>
				<div class="col-sm-10">
					<input type="text" name="itemname" placeholder="请输入名称"
						class="form-control" required="" value="${role.itemname}" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">负责人：</label>
				<div class="col-sm-10">
					<input type="text" name="projectLeader" placeholder="请输入名称"
						class="form-control" required="" value="${role.projectLeader}" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">项目状态：</label>
				<div class="col-sm-10">
					<input type="radio" name="itemstatus" 
						  value="0" />未开始
						<input type="radio" name="itemstatus" 
						  value="1" />正在进行
						<input type="radio" name="itemstatus" 
						  value="2" />已结束
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">项目链接：</label>
				<div class="col-sm-10">
					<input type="text" name="url" placeholder="请输入名称"
						class="form-control" required="" value="${role.url}" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">项目描述：</label>
				<div class="col-sm-10">
					<textarea rows="5" cols="5" name="itemdescribe" placeholder="请输入角色描述"
						class="form-control" >${role.itemdescribe}</textarea>
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<div class="form-group">
				<div class="col-sm-3 col-sm-offset-9">
					<button class="btn btn-primary" type="submit">保存内容</button>
				</div>
			</div>

		</form>
<script>
            initradio('itemstatus');
        </script>
	</div>

	</div>

	<script src="<%=request.getContextPath()%>/views/sysdefault/js/jquery.min.js?v=2.1.4"></script>
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/content.min.js?v=1.0.0"></script>
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/plugins/toastr/toastr.min.js"></script>
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/plugins/layer/layer.js"></script>
    
    <script type="text/javascript">
    
    var basePath = '<%=request.getContextPath()%>';
    
    toastr.options = {
  		  "closeButton": true,
  		  "debug": false,
  		  "progressBar": true,
  		  "positionClass": "toast-top-left",
  		  "showDuration": "400",
  		  "hideDuration": "1000",
  		  "timeOut": "3000",
  		  "extendedTimeOut": "1000",
  		  "showEasing": "swing",
  		  "hideEasing": "linear",
  		  "showMethod": "fadeIn",
  		  "hideMethod": "fadeOut"
  		}
    
    var addRole = function(){
    	
    	var index;
    	
    	$.ajax({
			type : "POST",
			url : basePath + "/system/addItem.ido",
			data : $("#subForm").serialize(),
			dataType : "json",
			success : function(msg) { 
				if (msg.errCode == '1') {
					parent.layerCallBack('1');
				}else{
					toastr.error(msg.errMsg, "提示");
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				toastr.error("系统出错！", "提示");
			},
			beforeSend : function(XMLHttpRequest){
				index = layer.load(0, {
					  shade: [0.3,'#ccc'] //0.1透明度的白色背景
					});
			},
			complete : function(XMLHttpRequest, textStatus){
				layer.close(index);
			}
		});
	
		return false;
    }
   
    
    </script>
    
</body>

</html>